const Service = require('egg').Service;

class MemberService extends Service {
    async member_register(params) {
        const Member = this.ctx.model.Member,
            newMember = new Member(params);
        return await this.ctx.model.Member.saveMember(newMember);
    }
    async member_add(params) {
        const Member = this.ctx.model.Member,
            newMember = new Member(params);
        return await this.ctx.model.Member.saveMember(newMember);
    }
    async member_findById(id) {
        return await this.ctx.model.Member.findById(id);
    }
    async member_unique(unique) {
        console.log('18,,,', unique);
        return await this.ctx.model.Member.findByUnique(unique);
    }
    async member_login(mail) {
        return await this.ctx.model.Member.findByMail(mail);
    }
    async member_list() {
        return await this.ctx.model.Member.findAll({});
    }
    async member_avatars(memberId) {
        return await this.ctx.model.Member.findById(memberId);
    }
    async member_update(uid, params) {
        return await this.ctx.model.Member.updateUser(uid, params);
    }
    async member_delete(uid) {
        return await this.ctx.model.Member.deleteUser(uid);
    }
    async add_article(params) {
        return await this.ctx.model.Member.add_article(params);
    }
    async del_article({uid, aid}) {
        return await this.ctx.model.Member.del_article({uid, aid});
    }
    async add_collect({uid, aid}) {
        return await this.ctx.model.Member.addCollect({uid, aid});
    }
    async cut_collect({uid, aid}) {
        console.log('46...', uid, aid);
        return await this.ctx.model.Member.cutCollect({uid, aid});
    }
}

module.exports = MemberService;